package com.lzz.bottomencapsulation.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.lzz.bottomencapsulation.mvp.MVPBaseFragment;

import java.util.ArrayList;
import java.util.List;



/**
 * viewpage  嵌套fragment适配器
 */
public class FragmentAdapter<T extends MVPBaseFragment> extends FragmentPagerAdapter {
    List<T> fragmentList = new ArrayList<T>();

    public FragmentAdapter(FragmentManager fm, List<T> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }

    @Override
    public Fragment getItem(int position) {

        return fragmentList.get(position);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    ArrayList<String> titles;

    public void setTitles(ArrayList<String> titles) {
        this.titles = titles;
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

}
